package ar.edu.utn.frsf.tpae.a2013.g04.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;

import ar.edu.utn.frsf.tpae.a2013.g04.persistence.dao.CentroCostoDAO;
import ar.edu.utn.frsf.tpae.a2013.g04.persistence.model.CentroCosto;
import ar.edu.utn.frsf.tpae.a2013.g04.service.CentroCostoService;

public class CentroCostoServiceImp implements CentroCostoService{

	private CentroCostoDAO ccoDAO;
	
	public CentroCostoDAO getCcoDAO() {
		
		try {
			return ccoDAO;
		}
		catch (RuntimeException e) {
			e.printStackTrace();
			return null;
		}
		catch (Exception e) {
			e.printStackTrace();
			return null;
		}
	}
	
	@Autowired(required = true)
	public Integer setCcoDAO(CentroCostoDAO ccoDAO) {
		Integer rcode= new Integer(0);

		try {
			this.ccoDAO = ccoDAO;
			rcode= 0;
		}
		catch (RuntimeException e) {
			e.printStackTrace();
			rcode= -2;
		}
		catch (Exception e) {
			e.printStackTrace();
			rcode= -1;
		}
		return rcode;
		
	}
	@Override
	public List<CentroCosto> listar() {
		
		try {
			return ccoDAO.listar();
		}
		catch (RuntimeException e) {
			e.printStackTrace();
			return null;
		}
		catch (Exception e) {
			e.printStackTrace();
			return null;
		}
		
	}

}
